<template>
	<view class="container">
		<!-- 蓝色背景区域 -->
		<view class="blue-bg"></view>
		
		<!-- 内容区域 -->
		<view class="content">
			<!-- 商铺信息卡片 -->
			<view class="shop-card">
				<!-- 加油站图片 -->
				<view class="image-wrapper">
					<image class="station-image" :src="stationImage" mode="aspectFill"></image>
				</view>
				
				<!-- 加油站信息 -->
				<view class="info-content">
					<view class="station-title">{{name}} ({{branch}})</view>
					<view class="info-item">营业时间：{{businessHours}}</view>
					<view class="info-item location">
						位置：{{address}}
						<image 
							class="nav-icon" 
							src="/static/plane@2x.png" 
							mode="aspectFit"
							@click="goToNavigation"
						></image>
					</view>
				</view>
			</view>
			
			<!-- 油价详情卡片 -->
			<view class="price-card">
				<view class="section-title">油价详情</view>
				<view class="price-list">
					<view class="price-item" v-for="(price, type) in oilPrices" :key="type">
						<text class="oil-type">{{type}}</text>
						<text class="price">¥{{price}}/L</text>
					</view>
				</view>
			</view>
		</view>
		
		<!-- 可拖动的呼叫按钮 -->
		<movable-area class="movable-area">
			<movable-view 
				class="movable-view"
				direction="all"
				x="600"
				y="200"
			>
				<image 
					class="call-icon" 
					src="/static/电话2@2x.png" 
					mode="aspectFit"
					@click="makeCall"
				></image>
			</movable-view>
		</movable-area>
	</view>
</template>

<script>
export default {
	data() {
		return {
			id: '',
			name: '',
			branch: '解放路店',
			address: '',
			businessHours: '',
			stationImage: '',
			oilPrices: {
				'92#': '',
				'95#': '',
				'98#': '',
				'0#': ''
			},
			phone: '400-000-0000',
			latitude: 0,
			longitude: 0,
			price: ''
		}
	},
	onLoad(options) {
		// 接收传递的数据
		this.id = options.id
		this.name = options.name
		this.address = options.address
		this.latitude = parseFloat(options.latitude || 0)
		this.longitude = parseFloat(options.longitude || 0)
		this.businessHours = options.businessHours
		this.stationImage = options.image || '/static/index_活动2.png'
		
		// 设置所有油号的价格
		const price = options.price || '0.00'
		this.oilPrices = {
			'92#': price,
			'95#': price,
			'98#': price,
			'0#': price
		}
		
		// 这里可以根据 id 请求获取更多数据
		// this.fetchStationDetail(this.id)
	},
	methods: {
		// 可以添加获取详细数据的方法
		async fetchStationDetail(id) {
			try {
				// const res = await api.getStationDetail(id)
				// 更新详细数据
			} catch (err) {
				uni.showToast({
					title: '获取数据失败',
					icon: 'none'
				})
			}
		},
		goToNavigation() {
			uni.navigateTo({
				url: `/packagesMap/navigation/navigation?name=${this.name}&address=${this.address}&latitude=${this.latitude}&longitude=${this.longitude}`
			})
		},
		makeCall() {
			uni.makePhoneCall({
				phoneNumber: this.phone
			})
		}
	}
}
</script>

<style>
.container {
	min-height: 100vh;
	background: #f5f5f5;
}

.blue-bg {
	position: absolute;
	top: 0;
	left: 0;
	right: 0;
	height: 360rpx;
	background-color: #2979ff;
}

.content {
	position: relative;
	z-index: 1;
	padding: 24rpx;
}

/* 商铺信息卡片 */
.shop-card {
	background: #FFFFFF;
	border-radius: 16rpx;
	margin-bottom: 24rpx;
}

.image-wrapper {
	padding: 24rpx 24rpx 0;
}

.station-image {
	width: 100%;
	height: 384rpx;
	border-radius: 12rpx;
}

.info-content {
	padding: 32rpx;
}

.station-title {
	font-size: 32rpx;
	color: #333;
	margin-bottom: 24rpx;
	font-weight: bold;
}

.info-item {
	font-size: 28rpx;
	color: #666;
	line-height: 48rpx;
}

.location {
	display: flex;
	align-items: center;
	justify-content: space-between;
}

.nav-icon {
	width: 32rpx;
	height: 32rpx;
}

/* 油价详情卡片 */
.price-card {
	background: #FFFFFF;
	border-radius: 16rpx;
	padding: 32rpx;
}

.section-title {
	font-size: 32rpx;
	color: #333;
	margin-bottom: 32rpx;
	font-weight: bold;
}

.price-list {
	display: flex;
	flex-direction: column;
}

.price-item {
	display: flex;
	justify-content: space-between;
	align-items: center;
	font-size: 32rpx;
	padding: 24rpx 120rpx;
	border-bottom: 1rpx solid #f5f5f5;
}

.price-item:last-child {
	border-bottom: none;
}

.oil-type {
	color: #333;
}

.price {
	color: #FF9500;
}

/* 可拖动按钮样式 */
.movable-area {
	position: fixed;
	width: 100%;
	height: 100%;
	top: 0;
	left: 0;
	pointer-events: none;
	z-index: 100;
}

.movable-view {
	width: 130rpx;
	height: 130rpx;
	pointer-events: auto;
	display: flex;
	align-items: center;
	justify-content: center;
}

.call-icon {
	width: 100rpx;
	height: 100rpx;
}
</style>
